/**
 * 
 */
package com.dsteiner.widgets.client.model;

import java.beans.PropertyChangeListener;

import com.dsteiner.widgets.client.PropertyChangeCollection;

public class FileUploadModel {
	protected PropertyChangeCollection propertyChangeSupport = new PropertyChangeCollection(
			this);

	private String submitResult;
	
	private boolean submitted;

	private String actionUrl;

	private String title;

	public void addPropertyChangeListener(String propertyName,
			PropertyChangeListener listener) {
		propertyChangeSupport.registerPropertyChangeListener(propertyName,
				listener);
	}

	private Integer maxFileSize;

	public Integer getMaxFileSize() {
		return maxFileSize;
	}

	public void setMaxFileSize(Integer maxFileSize) {
		Integer oldMaxFileSize = this.maxFileSize;
		this.maxFileSize = maxFileSize;
		propertyChangeSupport.firePropertyChange("maxFileSize", oldMaxFileSize, maxFileSize);
	}
	
	public String getActionUrl() {
		return actionUrl;
	}

	public String getSubmitResult() {
		return submitResult != null ? submitResult.replace("<pre>", "").replace("</pre>", "") : null;
	}
	
	public String getTitle() {
		return title;
	}
	
	public boolean isSubmitted() {
		return submitted;
	}

	public void setActionUrl(String actionUrl) {
		String oldActionUrl = this.actionUrl;
		this.actionUrl = actionUrl;
		propertyChangeSupport.firePropertyChange("actionUrl", oldActionUrl, actionUrl);
	}

	public void setSubmitResult(String submitResult) {
		String oldSubmitResult = this.submitResult;
		this.submitResult = submitResult;
		propertyChangeSupport.firePropertyChange("submitResult", oldSubmitResult, submitResult);
	}

	public void setSubmitted(boolean submitted) {
		boolean oldSubmitted = this.submitted;
		this.submitted = submitted;
		propertyChangeSupport.firePropertyChange("submitted", oldSubmitted, submitted);
	}

	public void setTitle(String title) {
		String oldTitle = this.title;
		this.title = title;
		propertyChangeSupport.firePropertyChange("title", oldTitle, title);
	}
}